﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Threading;
using System.Diagnostics;

using Styx;
using Styx.Combat.CombatRoutine;
using Styx.Helpers;
using Styx.Logic;
using Styx.Logic.BehaviorTree;
using Styx.Logic.Combat;
using Styx.Logic.Pathing;
using Styx.Logic.POI;
using Styx.WoWInternals.WoWObjects;
using TreeSharp;
using Action = TreeSharp.Action;
using Sequence = TreeSharp.Sequence;
using Styx.WoWInternals;


namespace Healz.Druid
{
    public static class Main
    {
        public static Config Settings;


        // So we can heal more than 1 person at a time ( lowest health )
        // Just say they have every hot on them, go to next person      
        public static void Pulse(int ElementAt)
        {
            // Just do check @ first element
            if (ElementAt == 0)
            {
                // Checks
                if (StyxWoW.GlobalCooldown) return;
                if (StyxWoW.Me.IsCasting) return;
                if (StyxWoW.Me.Stunned) return;
                if (StyxWoW.Me.Dead) return;
                if (StyxWoW.Me.Mounted) return;
                if (StyxWoW.Me.ManaPercent <= 7) return;
            }

            // Get our best player
            WoWPlayer BestPlayer = PlayerManager.PlayerToHeal(ElementAt);

            // No one to heal
            if (BestPlayer == null) return;
        }

        public static void CheckDoHeal(WoWPlayer Player, int ElementAt)
        {
            // fucken check for n00bs dieing fucken
            // INSTA HEALZ BABY
            if (Spells.Swiftmend.Pulse(Player)) return;
            if (Spells.NaturesSwiftness.Pulse(Player)) return;

            // Start of normal spells fucken
            if (Spells.Rejuvenation.Pulse(Player)) return;


            // We got to end, 
            // Means we didnt cast anything, Pulse again at next element
            ElementAt += 1;
            Pulse(ElementAt);
        }

    }
}
